package com.rulin.asp.business.datacleaning;

import java.util.List;

import org.apache.commons.lang3.tuple.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.rulin.asp.business.service.DictionaryService;
import com.rulin.asp.util.Tools;

@Controller
@RequestMapping("/dataList")
public class DataListController {

	@Autowired
	private DictionaryService dictionaryService;
	
	@Autowired
	private DataListService dataListService;
	
	@RequestMapping(value = "/dataListPage.html", method = RequestMethod.GET)
	public ModelAndView paperResultListPage(ModelAndView view){
		view.addObject("majors", dictionaryService.getByModel("clean_major_type"));
		view.addObject("subjects", dictionaryService.getByModel("clean_subject_type"));
		view.setViewName("business/datacleaning/datalist");
		return view;
	}
	
	@RequestMapping(value = "/getList.json", method = RequestMethod.GET)
	@ResponseBody
	public String list(QueryParamBean bean){
		Pair<Integer,List<QueryResultRowBean>> pair= dataListService.getListByParam(bean);
		return Tools.toEasyuiDataGrid(pair.getLeft(), pair.getRight());
	}
}
